
import java.io.IOException;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Amira
 */
public class Monster extends Sprite {

    int position_x;
    int position_y;
    int speed_x;
    int speed_y;
    int[] frame_sequence = {0, 1, 2, 3};

    public Monster(int x, int y) throws IOException {
        super(Image.createImage("/resource/ghost.png"), 20, 20);
        position_x = x;
        position_y = y;
        speed_x = 20 * x;
        speed_y = 20 * y + 51;
        defineReferencePixel(0, 0);
        setRefPixelPosition(speed_x, speed_y);
        setFrameSequence(frame_sequence);
        setFrame(0);
    }

    public void move() {
        nextFrame();
    }

    public void Move(boolean canMove, boolean up) {
        if (canMove) {
            if (up) {
                speed_y--;
            } else {
                speed_y++;
            }

            setPosition(speed_x, speed_y);
        }
    }
}
